import React, {Component} from "react";

export default class FirstComponent extends Component {
  constructor() {
    super();
    this.state = {
      innerWidth: window.innerWidth
    }
  }

  componentDidMount() {
    window.addEventListener('resize', this.handleResize.bind(this));
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.handleResize.bind(this))
  }

  handleResize() {
    this.setState({
      innerWidth: window.innerWidth,
    })
  }

  render() {
    return (
        <div className="" style={{fontSize: this.state.innerWidth / 1000 * 32}}>
          第一个组件
        </div>
    );
  }
}
